package OrderService

import (
	"context"
	"gdshop-back-end-go/client-api/app/request/OrderReq"
	"gdshop-back-end-go/client-api/app/response/OrderResp"
)

// 单条信息下单，通常是从商品详情过来的
func DoCreateOneData(ctx context.Context, parames *OrderReq.Create) (*OrderResp.Create, error) {
	var orderList []*OrderResp.OrderItem
	var goodsList []*OrderReq.GoodsItem
	goodsList = append(goodsList, &OrderReq.GoodsItem{
		GoodsId:       parames.OneData.GoodsId,
		GoodsNum:      parames.OneData.GoodsNum,
		GoodsOptionId: uint(parames.OneData.GoodsOptionId),
		TuanData:      parames.OneData.TuanData,
	})
	createByGroup, err := DoCreateByGroup(ctx, goodsList, parames.MemberId, parames.OneData.CouponIds, 0)
	if err != nil {
		return nil, err
	}
	orderList = append(orderList, createByGroup)
	return &OrderResp.Create{
		OrderList: orderList,
		Discounts: []*OrderResp.DiscountItem{},
	}, nil
}
